<?php


namespace app\admin\model\official;


use think\Model;


class BaseModel extends Model
{

    protected static function init()
    {
        self::afterInsert(function ($row) {
            if (!$row['weigh']) {
                $pk = $row->getPk();
                $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
            }
        });
    }

    /**
     * 关联栏目数据
     * @return \think\model\relation\HasOne
     */
    public function OfficialCategory()
    {
        return $this->hasOne('official_category', 'id', 'official_category_id');
    }


}